home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
amigadoslibrary
/
exnext.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-10
|
2KB
|
69 lines
/* ExNext.c V1.0 93-09-27 */
/* ROM library: "dos.library/ExNext", (All versions) */
/* Copyright 1993, Anders Bjerin, Amiga C Club */
#include <dos/dos.h>
#include <exec/memory.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <stdio.h>
#include <stdlib.h>
UBYTE *version = "$VER: ExNext 1.0";
int main( int argc, char *argv[] );
int main( int argc, char *argv[] )
{
BPTR my_lock;
struct FileInfoBlock *my_fib;
/* 1. Lock the directory: */
my_lock = Lock( "RAM:", SHARED_LOCK );
if( !my_lock )
{
printf( "Could not lock the object!\n" );
exit( 20 );
}
/* 2. Allocate a FileInfoBlock structure: */
my_fib = (struct FileInfoBlock *)
AllocMem( sizeof( struct FileInfoBlock ), MEMF_ANY | MEMF_CLEAR );
if( !my_fib )
{
printf( "Not enough memory!\n" );
UnLock( my_lock );
exit( 21 );
};
/* 3. Examine the locked object: */
if( Examine( my_lock, my_fib ) )
{
/* 4. Check if it is a directory or volume: */
if( my_fib->fib_DirEntryType > 0 )
{
printf( "%s\n", my_fib->fib_FileName );
/* 5. As long as we find objects we stay in the loop: */
while( ExNext( my_lock, my_fib ) )
printf( " %s\n", my_fib->fib_FileName );
/* Were all objects listed? */
if( IoErr() == ERROR_NO_MORE_ENTRIES )
printf( "No more files!\n" );
else
printf("Error while reading!\n");
}
else
printf( "This program needs a directory or volume name!\n" );
}
else
printf( "Could not examine the object!\n" );
FreeMem( my_fib, sizeof( struct FileInfoBlock ) );
UnLock( my_lock );
exit( 0 );
}